package com.aisino.springai.demos.chat.config;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.embedding.DashScopeEmbeddingModel;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeCloudStore;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeStoreOptions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

// @Configuration
public class BailianConfig {

    @Value("${spring.ai.dashscope.api-key}")
    private String apiKey;


    @Bean
    public DashScopeApi dashScopeApi() {
        System.out.println("apiKey = " + apiKey);
        return new DashScopeApi(apiKey);
    }

    @Bean
    public DashScopeEmbeddingModel embeddingModel(DashScopeApi api) {
        return new DashScopeEmbeddingModel(api);
    }

    @Bean
    public DashScopeStoreOptions storeOptions() {
        return new DashScopeStoreOptions("my-knowledge-base");
    }

    @Bean
    public DashScopeCloudStore vectorStore(DashScopeApi api,
                                           DashScopeStoreOptions options) {
        return new DashScopeCloudStore(api, options);
    }
}